package windbell.domain.risk.impl;

import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;
import windbell.domain.risk.RiskCheck;
import windbell.domain.risk.RiskCheckCriteria;
import windbell.domain.risk.RiskCheckSource;
import windbell.domain.risk.RiskCheckStatus;
import windbell.domain.risk.RiskCheckTarget;

public class RiskCheckCriteriaImpl extends HQLBasedPagedQueryCriteria<RiskCheck> implements RiskCheckCriteria {
  private RiskCheckTarget checkTarget;
  
  public RiskCheckTarget getCheckTarget() {
    return this.checkTarget;
  }
  
  public RiskCheckCriteria setCheckTarget(final RiskCheckTarget checkTarget) {
    this.checkTarget = checkTarget;
    return this;			
    
  }
  
  private RiskCheckSource source;
  
  public RiskCheckSource getSource() {
    return this.source;
  }
  
  public RiskCheckCriteria setSource(final RiskCheckSource source) {
    this.source = source;
    return this;			
    
  }
  
  private RiskCheckStatus status;
  
  public RiskCheckStatus getStatus() {
    return this.status;
  }
  
  public RiskCheckCriteria setStatus(final RiskCheckStatus status) {
    this.status = status;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from windbell.domain.risk.impl.RiskCheckImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCheckTarget()) ){
    	hql += " and ((this.checkTarget) = (:checkTarget))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSource()) ){
    	hql += " and ((this.source) = (:source))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus()) ){
    	hql += " and ((this.Status) = (:status))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCheckTarget())){
    	query.setParameter("checkTarget",getCheckTarget()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSource())){
    	query.setParameter("source",getSource()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus())){
    	query.setParameter("status",getStatus()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RiskCheckCriteriaImpl() {
    initOrderBys();
  }
}
